﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Obra.SmugMug.Api
{
    /// <summary>
    /// Image EXIF data.
    /// </summary>
    /// <remarks>
    /// <para>
    /// SmugMug uses (overloads) the Image element for an image, and for image 
    /// EXIF data.  Thankfully, I do not explicitly deserialize an image, rather
    /// I always deserialize Images.
    /// </para>
    /// <para>
    /// Some of the data capture are returned as string, but perhaps should be
    /// converted to a more approriate type such as a rational.  I don't have
    /// enough real-world EXIF to know if this is doable or not.
    /// </para>
    /// </remarks>
    [XmlRoot("Image")]
    public class ImageExif : 
        ResponseWithIdContract
    {
        [XmlAttribute("DateTime")]
        public string DateTimeString
        {
            get;
            set;
        }

        public DateTime DateTime
        {
            get { return SmugMugDateTime.Parse(this.DateTimeString); }
        }

        [XmlAttribute("DateTimeOriginal")]
        public string DateTimeOriginalString
        {
            get;
            set;
        }

        public DateTime DateTimeOriginal
        {
            get { return SmugMugDateTime.Parse(this.DateTimeOriginalString); }
        }

        [XmlAttribute("DateTimeDigitized")]
        public string DateTimeDigitizedString
        {
            get;
            set;
        }

        public DateTime DateTimeDigitized
        {
            get { return SmugMugDateTime.Parse(this.DateTimeDigitizedString); }
        }

        [XmlAttribute]
        public string Make
        {
            get;
            set;
        }

        [XmlAttribute]
        public string Model
        {
            get;
            set;
        }

        [XmlAttribute]
        public string ExposureTime
        {
            get;
            set;
        }

        [XmlAttribute]
        public string Aperture
        {
            get;
            set;
        }

        [XmlAttribute("ISO")]
        public int Iso
        {
            get;
            set;
        }

        [XmlAttribute]
        public string FocalLength
        {
            get;
            set;
        }


        [XmlAttribute]
        public int FocalLengthIn35mmFilm
        {
            get;
            set;
        }

        [XmlAttribute("CCDWidth")]
        public string CcdWidth
        {
            get;
            set;
        }

        [XmlAttribute]
        public string CompressedBitsPerPixel
        {
            get;
            set;
        }

        [XmlAttribute]
        public int Flash
        {
            get;
            set;
        }

        [XmlAttribute]
        public int Metering
        {
            get;
            set;
        }

        [XmlAttribute]
        public int ExposureProgram
        {
            get;
            set;
        }

        [XmlAttribute]
        public string ExposureBiasValue
        {
            get;
            set;
        }

        [XmlAttribute]
        public int ExposureMode
        {
            get;
            set;
        }

        [XmlAttribute]
        public int LightSource
        {
            get;
            set;
        }

        [XmlAttribute]
        public int WhiteBalance
        {
            get;
            set;
        }

        [XmlAttribute]
        public string DigitalZoomRatio
        {
            get;
            set;
        }

        [XmlAttribute]
        public int Contrast
        {
            get;
            set;
        }

        [XmlAttribute]
        public int Saturation
        {
            get;
            set;
        }
        
        [XmlAttribute]
        public int Sharpness
        {
            get;
            set;
        }

        [XmlAttribute]
        public string SubjectDistance
        {
            get;
            set;
        }

        [XmlAttribute]
        public int SubjectDistanceRange
        {
            get;
            set;
        }

        [XmlAttribute]
        public int SensingMethod
        {
            get;
            set;
        }

        [XmlAttribute]
        public string ColorSpace
        {
            get;
            set;
        }

        [XmlAttribute]
        public string Brightness
        {
            get;
            set;
        }
    }
}
